﻿///////////////////////////////////////////////////////////////////////////////
// File:        ConnectionFactory.hpp
// Author:      671643387@qq.com
// Description:
///////////////////////////////////////////////////////////////////////////////

#ifndef NIO_NET_CONNECTIONFACTORY_HPP_
#define NIO_NET_CONNECTIONFACTORY_HPP_

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif

#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/pool/object_pool.hpp>
#include <nio/Types.hpp>
#include <nio/net/Connection.hpp>

namespace nio
{
    namespace net
    {
        class ConnectionFactory : public boost::noncopyable
        {
        public:
            ConnectionFactory(void);
            virtual ~ConnectionFactory(void);

        public:
            virtual ConnectionPtr create(sock_t sock, unsigned int isSize, unsigned int osSize);

        private:
            void destroy(Connection* conn);

        private:
            boost::object_pool<Connection> connPool_;
        };

        typedef boost::shared_ptr<ConnectionFactory> ConnectionFactoryPtr;
    }
}

#endif //NIO_NET_CONNECTIONFACTORY_HPP_
